//
//  MYGlobal.m
//  PetExchange
//
//  Created by a on 2020/12/17.
//

#import "MYGlobal.h"
//用户信息存储路径
#define dingPath [NSString stringWithFormat:@"%@/Documents/ding.txt",NSHomeDirectory()]
@implementation MYGlobal
+(MYGlobal *)share{
    static MYGlobal *sharedGlobalInstance = nil;
    static dispatch_once_t predicate;
    dispatch_once(&predicate, ^{
        sharedGlobalInstance = [[self alloc] init];
    });
    return sharedGlobalInstance;
}

-(id)init{
    self=[super init];
    if (self) {
        self.wechatFlag = 0;
        self.gwIP = @"";
    }
    return self;
}
//保存数据
-(void)saveDataWithDict:(NSArray *)array{
    if (array == nil) {
        return;
    }
    NSData *resultData= [NSJSONSerialization dataWithJSONObject:array options:NSJSONWritingPrettyPrinted error:nil];
    NSFileManager *fm=[NSFileManager defaultManager];
    if (![fm fileExistsAtPath:dingPath]) {
        [fm createFileAtPath:dingPath contents:nil attributes:nil];
    }
    [resultData writeToFile:dingPath atomically:YES];
}
//得到数据
-(NSArray *)getData{
    NSData *data = [NSData dataWithContentsOfFile:dingPath];
    NSArray *dict;
    if (data) {
        dict = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:dingPath] options:NSJSONReadingMutableContainers error:nil];
    }else{
        dict = [[NSArray alloc] init];
    }
    return dict;
}

-(NSString *)getMoney:(NSString *)str1 withTwo:(NSString *)str2 withThree:(NSString *)str3{
//    let num1 = [str];
    return  @"";
}

@end
